<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
    <meta name = "format-detection" content = "telephone=no">
    <title>自提地址</title>
    <link rel="stylesheet" href="__PUBLIC__/Home/css/address.css">
    <include file="Public/common_js"/>
</head>
<body>
<div class="warp">
    <div class="location-box" style="display:block;">
        <div class="user-phone">
            <span>提货人电话:</span>
            <p>
                <input type="text" value="{$data.mobile}" id="mobile">
            	<h5>该电话用作提取自提时候的凭证。</h5>
            </p>
        </div>
        <div class="location-result pdLR">
            <ul>

            <volist name="zTList" id="zt" >
                <li data-local="{$data.local_id}" data-id="{$zt.dot_id}">
    				<p class="clearfix"><span class="md-name">{$zt.store_dot_name}</span><if condition="$zt['dot_id'] eq $data['dot_id']"><span class="current">当前</span></if></p>
                    <p>提货时间：<span>{$zt.tihuo_time}</span></p>
                    <p class="address">{$zt.area_text}{$zt.addr}</p>
                </li>
            </volist>

            </ul>
        </div>
    </div>
</div>
<script src="__PUBLIC__/Home/js/validate.js"></script>
<script type="text/javascript">
   require(['base']);
   var _isAjaxClick = false;
   $("div.location-result ul li").click(function(){
	   if(_isAjaxClick) return;
	   _isAjaxClick = true;
       var dotid =$(this).data('id');
       var _mobile = $('#mobile').val();
       var local_id=$(this).data('local');
	   var msg = mbValidator.isMobile(_mobile);
       if(msg != ""){
           _global.promote.alertPopup(msg);
		   _isAjaxClick = false;
           return false;
       }

       $.ajax({
           url:"{:U('Carts/changeLocalDot')}",
           type:'post',
           datatype:'json',
           data:{'dot_id':dotid, 'mobile': _mobile, 'local_id':local_id,'store_dot_name':$(this).find('.md-name').text()},
           success:function (data) {
              window.location.href="{:url('Home/Carts/cart')}";
			  _isAjaxClick = false;
           },
           error:function (err) {
			   _global.promote.alertPopup("服务器异常，请稍后重试！"); 
			   _isAjaxClick = false;
           }
       })
    });
</script>
</body>
</html>
